package com.tank.jdk8.collecet;

import com.tank.jdk8.Student;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

import java.util.Arrays;
import java.util.List;
import java.util.Spliterator;
import java.util.stream.Collectors;

/**
 * Created with IntelliJ IDEA.
 * User: SuQiEr
 * Date:2017/4/9 0009
 * Time: 下午 5:25
 * To change this template use File | Settings | File Templates.
 */
@Slf4j
public class MyCollectorTest3 {

    //累加double
    @Test
    public void testSummingDouble(){

        List<Student> studentList = Arrays.asList(new Student("20.00"), new Student("20.01"), new Student("22.00"));
        List<Double> list = studentList.stream().map(item -> new Double(item.getMoney())).collect(Collectors.toList());
        Double sum = list.stream().collect(Collectors.summingDouble(item -> item));
        log.info("sum:{}", sum);
    }
}
